import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_overlay_loader/flutter_overlay_loader.dart';
import 'package:loading_indicator/loading_indicator.dart';

import '../wcao/ui/theme.dart';

///Hud工具类
class HudUtil {
  static ready() {
    EasyLoading.instance
      ..displayDuration = const Duration(milliseconds: 2000)
      ..indicatorType = EasyLoadingIndicatorType.circle
      ..loadingStyle = EasyLoadingStyle.custom
      ..backgroundColor = Colors.transparent
      ..indicatorColor = Colors.transparent
      ..textColor = Colors.transparent
      ..maskColor = Colors.black.withOpacity(0.5)
      ..userInteractions = true
      ..dismissOnTap = true;
  }

  static show({String msg = "加载中...", bool dismissOnTap = false}) {
    EasyLoading.show(status: msg, dismissOnTap: dismissOnTap);
  }
  static showSend({String msg = "发送中...", bool dismissOnTap = false}) {
    EasyLoading.show(status: msg, dismissOnTap: dismissOnTap);
  }
  static showSuccess(String msg) {
    EasyLoading.showSuccess(msg);
  }

  static showFail(String msg) {
    EasyLoading.showError(msg);
  }

  static dismiss() {
    EasyLoading.dismiss();
  }

  static toast(String msg) {
    EasyLoading.showToast(msg, dismissOnTap: true);
  }
  static Future<void> showBeautifulFail(BuildContext context) async {
    EasyLoading.show(

        dismissOnTap: true,
        maskType:EasyLoadingMaskType.clear,
        indicator:  SizedBox(

          width: 66,
          height: 66,
          child:  LoadingIndicator(
            indicatorType: Indicator.lineSpinFadeLoader, /// Required, The loading type of the widget
            colors:  [Colors.white,WcaoTheme.primary,WcaoTheme.primaryOpacity],       /// Optional, The color collections
            strokeWidth: 1,                     /// Optional, The stroke of the line, only applicable to widget which contains line
            backgroundColor: Colors.transparent,
          ),
        ));
  }

    static Future<void> showBeautiful(BuildContext context) async {
    // Loader.show(context,
    //     isSafeAreaOverlay: false
    //     ,
    //     isBottomBarOverlay: true,
    //
    //     overlayColor: Colors.black26,
    //     progressIndicator: SizedBox(
    //       width: 50,
    //       height: 50,
    //       child:  LoadingIndicator(
    //         indicatorType: Indicator.ballScaleMultiple, /// Required, The loading type of the widget
    //         colors:  [Colors.white,WcaoTheme.primary,WcaoTheme.primaryOpacity],       /// Optional, The color collections
    //         strokeWidth: 1,                     /// Optional, The stroke of the line, only applicable to widget which contains line
    //
    //       ),
    //     ),
    //     themeData: Theme.of(context)
    //         .copyWith(colorScheme: ColorScheme.fromSwatch().copyWith(secondary: Colors.green))
    // );
    //
    // Loader.hide();
    EasyLoading.show(

        dismissOnTap: true,
        maskType:EasyLoadingMaskType.clear,
        indicator:  SizedBox(

          width: 66,
          height: 66,
          child:  LoadingIndicator(
            indicatorType: Indicator.ballScaleMultiple, /// Required, The loading type of the widget
            colors:  [Colors.white,WcaoTheme.primary,WcaoTheme.primaryOpacity],       /// Optional, The color collections
            strokeWidth: 1,                     /// Optional, The stroke of the line, only applicable to widget which contains line
            backgroundColor: Colors.transparent,
          ),
        ));
  }
}
